package org.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.ssm.dao.EmpDao;
import org.ssm.pojo.Emp;
import org.ssm.service.IEmpService;

import java.util.List;

@Service
public class EmpServiceImpl implements IEmpService {
    @Autowired
    private EmpDao empDao;

    public void setEmpDao(EmpDao empDao) {
        this.empDao = empDao;
    }

    @Override
    public Emp findEmp(Integer empno) {
        return empDao.selectOne(empno);
    }

    @Override
    public List<Emp> findAll() {
        // 设置分页的相关参数
        PageHelper.startPage(1,27);
        List<Emp> empList = empDao.selectAll();
        PageInfo<Emp> pageInfo = new PageInfo<>(empList);
        return empList;
    }

    @Override
    public void saveEmp(Emp emp) {
        empDao.insertEmp(emp);
    }

    @Override
    public void removeEmp(Integer empno) {
        empDao.deleteEmp(empno);
    }

    @Override
    public void modifyEmp(Emp emp) {
        empDao.updateEmp(emp);
    }


}
